﻿package plugin.duanzao.view
{
    import __AS3__.vec.*;
    import cmd.*;
    import com.core.*;
    import com.core.destroy.*;
    import com.sh.game.display.*;
    import com.sh.game.global.*;
    import com.sh.game.util.*;
    import consts.*;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.utils.*;
    import manager.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.duanzao.component.*;
    import plugin.taskdialog.consts.*;
    import pluginfw.nio.*;
    import uiresource.*;
    import view.*;
    import view.uilt.*;
    import vo.*;

    public class QiangHuaView extends QiangHuaUI
    {
        private var _curobj:Object;
        private var qh:Box;
        private var armid:int;
        private var lv:int;
        private var lvvalue:int;
        private var index:int;
        private var arr:Array;
        private var oPower:int = 0;
        private var pos:int;
        private var addspArr:Vector.<QhaddItem>;
        private var _cfgNewQh:Object;
        private var _cfgitems:Object;
        private var money:int;
        private var cost:int;
        private var type:int;
        private var addsp:VBox;
        private var _jdtw:int = 245;
        private var mc:XMLMovieClip;
        private var stripMc:XMLMovieClip;
        private var curpower:int;
        private var oldPower:int;
        private var powerSprite:PowerMove;
        private var useItemid:Array;
        private var successMc:XMLMovieClip;
        private var successXml:XML;
        private var failMc:XMLMovieClip;
        private var failXml:XML;
        private var upvalue:int;
        private var _storeids:Array;
        private var _storetids:Array;
        private var yuanbao1:int = 0;
        private var yuanbao2:int = 0;
        private var yuanbao3:int = 0;
        private var yuanbao4:int = 0;
        private var yuanbao5:int = 0;
        private var cfgStore:Object;
        private var shap:Shape;
        private var isShow:Boolean = false;
        private var curSuperLevel:int = 0;
        private var curSuperLevelmax:int = 0;
        private var maxObj:Object;
        private var cfgitem:Object;
        private var qhtz:Object;
        private var _qhtzTips:String;
        public static const successEffect:Class = QiangHuaView_successEffect;
        public static const failEffect:Class = QiangHuaView_failEffect;

        public function QiangHuaView() : void
        {
            this.arr = ConfigDictionary.data.armadd;
            this.addspArr = new Vector.<QhaddItem>;
            this._cfgNewQh = ConfigDictionary.data.newqh;
            this._cfgitems = ConfigDictionary.data.item;
            this.useItemid = [0];
            this._storeids = [Constant.STORE_YJQHS, Constant.STORE_EJQHS, Constant.STORE_SJQHS, Constant.STORE_GJQHS, Constant.STORE_QHBHF];
            this._storetids = [Constant.ITEM_YJQHS, Constant.ITEM_EJQHS, Constant.ITEM_SJQHS, Constant.ITEM_GJQHS, Constant.ITEM_QHBHF];
            this.cfgStore = ConfigDictionary.data.storeNew;
            this.cfgitem = ConfigDictionary.data.item;
            this.qhtz = ConfigDictionary.data.qhtz;
            return;
        }// end function

        override protected function initializeView() : void
        {
            item1.visible = false;
            item2.visible = false;
            this._cfgNewQh = ConfigDictionary.data.newqh;
            gailvLabel.isHtml = true;
            this.addsp = new VBox();
            this.addChild(this.addsp);
            this.addsp.x = 15;
            this.addsp.y = 152 + 127;
            jdtw.visible = false;
            btn_yjqh.visible = false;
            var _loc_1:Boolean = false;
            bhfBox.visible = false;
            qhbhfBox.visible = _loc_1;
            btn_qh.label = "铸造";
            btn_qh.x = 315 + 18;
            this.powerSprite = new PowerMove();
            this.powerSprite.x = 326;
            this.powerSprite.y = 295;
            this.addChild(this.powerSprite);
            this.successXml = new XML(new successEffect());
            App.mloader3.loadSWF(Config.getUrl("assets/images/mainui/qianghuasucces1.swf"), 1, new Handler(this.completeFunc1));
            this.failXml = new XML(new failEffect());
            App.mloader3.loadSWF(Config.getUrl("assets/images/mainui/qianghuaerror.swf"), 1, new Handler(this.completeFunc2));
            this.clear();
            ModelProxy.change("guideitem", "guideid" + GuideType.GUIDE_QH1, btn_qh);
            ModelProxy.change("guideitem", "guideid" + GuideType.GUIDE_QH12, btn_qh);
            this.setItemPrice();
            this.initEvent();
            shopLabel.addEventListener(MouseEvent.CLICK, this.onLabelClicked);
            wakuangLabel.addEventListener(MouseEvent.CLICK, this.onLabelClicked);
            swyLabel.addEventListener(MouseEvent.CLICK, this.onLabelClicked);
            XMLMcManager.instance.complatefuncs["qianghua"] = this.mcCompletefunc;
            tipsImg.addEventListener(MouseEvent.MOUSE_OVER, this.overHandler);
            tipsImg.addEventListener(MouseEvent.MOUSE_OUT, this.outHandler);
            return;
        }// end function

        public function mcCompletefunc() : void
        {
            this.clearEffect();
            this.mc = XMLMcManager.instance.getPluginMc("qianghua", "qh_quanquan");
            if (this.mc)
            {
                this.mc.mouseEnabled = false;
                this.mc.mouseChildren = false;
                this.mc.play();
                this.mc.interval = 1000 / 10;
                this.mc.blendMode = BlendMode.ADD;
                this.addChild(this.mc);
                this.showEffect();
            }
            if (this.isShow)
            {
                this.stripMc = XMLMcManager.instance.getPluginMc("qianghua", "qh_jindutiao");
                if (this.stripMc)
                {
                    this.shap = new Shape();
                    this.shap.graphics.beginFill(0, 1);
                    this.shap.graphics.drawRect(0, 0, 444, 80);
                    this.shap.graphics.endFill();
                    this.shap.x = jdtw.x + 2;
                    this.shap.y = jdtw.y - 20;
                    this.addChild(this.shap);
                    this.stripMc.mouseEnabled = false;
                    this.stripMc.mouseChildren = false;
                    this.stripMc.blendMode = BlendMode.ADD;
                    this.stripMc.x = this.stripMc.x + (jdtw.x + 2 - 530 + 116 + jdtw.width);
                    this.stripMc.y = jdtw.y - 35;
                    this.stripMc.play();
                    this.stripMc.mask = this.shap;
                    this.addChild(this.stripMc);
                }
            }
            return;
        }// end function

        override protected function createChildren() : void
        {
            loadUI("QiangHua.xml");
            return;
        }// end function

        private function onLabelClicked(event:MouseEvent) : void
        {
            var _loc_2:Object = null;
            if (event.currentTarget == shopLabel)
            {
                PluginManager.instance.openPlugin("store", shopLabel.localToGlobal(new Point(0, 0)), 1);
            }
            else if (event.currentTarget == wakuangLabel)
            {
                if (ItemUilt.checkMapIsFly())
                {
                    _loc_2 = ConfigDictionary.data.sysnpc[152];
                    PluginManager.instance.sendToServer("taskdialog", CMDTaskdialog.Fly, {x:_loc_2.x, y:_loc_2.y, tostageid:_loc_2.stageid});
                    ModelProxy.change("data", "taskfindpath", _loc_2.npcid);
                }
            }
            else if (event.currentTarget == swyLabel)
            {
                if (ItemUilt.checkMapIsFly())
                {
                    _loc_2 = ConfigDictionary.data.sysnpc[190];
                    PluginManager.instance.sendToServer("taskdialog", CMDTaskdialog.Fly, {x:_loc_2.x, y:_loc_2.y, tostageid:_loc_2.stageid});
                    ModelProxy.change("data", "taskfindpath", _loc_2.npcid);
                }
            }
            return;
        }// end function

        private function completeFunc1(param1:Object) : void
        {
            this.successMc = new XMLMovieClip("png.qianghua.succes", this.successXml);
            this.successMc.mouseChildren = false;
            this.successMc.interval = 165;
            this.successMc.mouseEnabled = false;
            this.successMc.x = 134;
            this.successMc.y = -180;
            this.successMc.visible = false;
            this.successMc.play();
            this.addChild(this.successMc);
            return;
        }// end function

        private function completeFunc2(param1:Object) : void
        {
            this.failMc = new XMLMovieClip("png.qianghuaerror", this.failXml);
            this.failMc.mouseChildren = false;
            this.failMc.mouseEnabled = false;
            this.failMc.interval = 165;
            this.failMc.x = 134;
            this.failMc.y = -180;
            this.failMc.visible = false;
            this.failMc.play();
            this.addChild(this.failMc);
            return;
        }// end function

        private function setItemPrice() : void
        {
            this.yuanbao1 = this.cfgStore[this._storeids[0]].nowprice;
            this.yuanbao2 = this.cfgStore[this._storeids[1]].nowprice;
            this.yuanbao3 = this.cfgStore[this._storeids[2]].nowprice;
            this.yuanbao4 = this.cfgStore[this._storeids[3]].nowprice;
            this.yuanbao5 = this.cfgStore[this._storeids[4]].nowprice;
            return;
        }// end function

        private function initEvent() : void
        {
            btn_qh.clickHandler = new Handler(this.qiangHua, [1]);
            btn_yjqh.clickHandler = new Handler(this.qiangHua, [2]);
            cbb.clickHandler = new Handler(this.showYuanbao);
            cbox.clickHandler = new Handler(this.showYuanbao);
            return;
        }// end function

        private function qiangHua(param1:int) : void
        {
            ModelProxy.change("guide", "hide", GuideType.GUIDE_QH1);
            ModelProxy.change("guide", "hide", GuideType.GUIDE_QH12);
            if (this.armid == 0)
            {
                WarningManager.show(69);
                return;
            }
            var _loc_2:* = ModelProxy.getValue("data", "qhflag");
            this.type = param1;
            this.qiangHua1();
            return;
        }// end function

        private function qiangHua1() : void
        {
            var _loc_1:int = 0;
            var _loc_2:Output = null;
            var _loc_3:int = 0;
            if (this.armid == 0)
            {
                return;
            }
            if (cbb.selected == true)
            {
                _loc_1 = 240202029;
            }
            else
            {
                _loc_1 = 0;
            }
            if (_loc_1 > 0 && this.type == 2)
            {
                ModelProxy.change("movetips", "error", "使用强化石强化不能一键强化");
                ModelProxy.change("data", "qhflag", false);
                btn_qh.disabled = false;
                btn_yjqh.disabled = false;
                return;
            }
            PluginManager.instance.playSound(SoundType.BTN_ARMON2);
            if (this.type == 1)
            {
                PluginManager.instance.sendToServer("qianghua", CMDQiangHua.QiangHua, {armid:this.armid, flag:cbox.selected, type:this.type, useitem:_loc_1});
            }
            else
            {
                _loc_2 = new Output();
                _loc_2.writeVarInt(this.armid, false);
                _loc_3 = 0;
                if (cbox.selected)
                {
                    _loc_3 = 1;
                }
                _loc_2.writeByte(_loc_3);
                PluginManager.instance.sendToBufferServer("qianghua", 30, _loc_2);
            }
            return;
        }// end function

        private function onQiangHua() : void
        {
            if (this.armid == 0)
            {
                return;
            }
            if (this.type == 2)
            {
                ModelProxy.change("data", "qhflag", false);
                btn_qh.disabled = false;
                btn_yjqh.disabled = false;
                return;
            }
            return;
        }// end function

        public function showPower(param1:int) : void
        {
            if (param1 < this.oPower)
            {
                this.oPower = 0;
            }
            var _loc_2:* = param1 - this.oPower;
            this.oPower = param1;
            if (this.stripMc)
            {
                this.stripMc.visible = true;
                this.stripMc.play();
            }
            return;
        }// end function

        private function showStar(param1:int, param2:int) : void
        {
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            var _loc_7:int = 0;
            var _loc_8:int = 0;
            var _loc_9:int = 0;
            var _loc_10:int = 0;
            var _loc_3:int = 1;
            while (_loc_3 <= 10)
            {
                
                this["s" + _loc_3].visible = false;
                _loc_3++;
            }
            var _loc_4:* = this.cfgitem[param1].qhmax;
            if (this.cfgitem[param1].qhmax <= 10)
            {
                _loc_5 = 1;
                while (_loc_5 <= _loc_4)
                {
                    
                    this["s" + _loc_5].visible = true;
                    _loc_5++;
                }
            }
            else if (_loc_4 > 10 && param2 < 10)
            {
                _loc_6 = 1;
                while (_loc_6 <= 10)
                {
                    
                    this["s" + _loc_6].visible = true;
                    _loc_6++;
                }
            }
            else if (_loc_4 > 10 && param2 >= 10)
            {
                _loc_7 = _loc_4 - 10;
                _loc_8 = 1;
                while (_loc_8 <= _loc_7)
                {
                    
                    this["s" + _loc_8].visible = true;
                    _loc_8++;
                }
            }
            if (param2 >= 10)
            {
                _loc_9 = 1;
                while (_loc_9 <= 10)
                {
                    
                    if (this["s" + _loc_9])
                    {
                        this["s" + _loc_9].url = "png.common.qh2";
                        this["star" + _loc_9].url = "png.common.qh1";
                    }
                    _loc_9++;
                }
            }
            else
            {
                _loc_10 = 1;
                while (_loc_10 <= 10)
                {
                    
                    if (this["s" + _loc_10])
                    {
                        this["s" + _loc_10].url = "png.common.star_1";
                        this["star" + _loc_10].url = "png.common.star";
                    }
                    _loc_10++;
                }
            }
            return;
        }// end function

        public function showItem(param1:Object = null) : void
        {
            var _loc_2:QhaddItem = null;
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            var _loc_5:Object = null;
            var _loc_6:int = 0;
            var _loc_7:int = 0;
            var _loc_8:int = 0;
            var _loc_9:Array = null;
            var _loc_10:Number = NaN;
            var _loc_11:int = 0;
            var _loc_12:int = 0;
            var _loc_13:int = 0;
            var _loc_14:int = 0;
            var _loc_15:int = 0;
            var _loc_16:int = 0;
            var _loc_17:int = 0;
            var _loc_18:Number = NaN;
            var _loc_19:String = null;
            var _loc_20:Object = null;
            var _loc_21:Object = null;
            var _loc_22:Number = NaN;
            if (param1 == null || mlist.array.length == 0)
            {
                this.clear();
                return;
            }
            this._curobj = param1;
            if (param1.level < 40)
            {
                ModelProxy.change("movetips", "error", "武器等级低于40级不能强化");
                return;
            }
            this.clear();
            DestroyUtil.removeChildren(this.addsp);
            this.lv = int(param1.superlevel);
            this.lvvalue = int(param1.upvalue);
            if (this.armid != param1.id)
            {
                this.oldPower = 0;
            }
            this.armid = param1.id;
            this.index = param1.index;
            item1.data = param1;
            this.curSuperLevel = param1.superlevel;
            this.curSuperLevelmax = param1.qhmax;
            this.pos = this.lv % 10;
            this.showStar(param1.itemid, this.lv);
            _loc_3 = this.lv + 1;
            if (_loc_3 > this.curSuperLevelmax)
            {
                _loc_3 = this.curSuperLevelmax;
            }
            img2.visible = true;
            img3.visible = true;
            if (this.lv < 10 && _loc_3 < 10)
            {
                img1.visible = false;
                img2.url = "cs2_duanzao/" + this.lv + ".png";
                img3.url = "cs2_duanzao/" + _loc_3 + ".png";
                img4.visible = false;
            }
            else if (this.lv < 10 && _loc_3 == 10)
            {
                img1.visible = false;
                img2.url = "cs2_duanzao/" + this.lv + ".png";
                img3.url = "cs2_duanzao/1.png";
                img4.visible = true;
                img4.url = "cs2_duanzao/0.png";
            }
            else if (this.lv >= 10 && this.lv <= 18)
            {
                img1.visible = true;
                img1.url = "cs2_duanzao/1.png";
                img2.url = "cs2_duanzao/" + (this.lv - 10) + ".png";
                img3.url = "cs2_duanzao/1.png";
                img4.visible = true;
                img4.url = "cs2_duanzao/" + (_loc_3 - 10) + ".png";
            }
            else if (this.lv > 18)
            {
                img1.visible = true;
                img1.url = "cs2_duanzao/1.png";
                img2.url = "cs2_duanzao/" + (this.lv - 10) + ".png";
                img3.url = "cs2_duanzao/2.png";
                img4.visible = true;
                img4.url = "cs2_duanzao/" + (_loc_3 - 20) + ".png";
            }
            if (this.pos > 0)
            {
                _loc_4 = 1;
                while (_loc_4 <= this.pos)
                {
                    
                    this["star" + _loc_4].visible = true;
                    _loc_4++;
                }
            }
            if (!item2.data || item2.data.itemid != param1.itemid)
            {
                _loc_5 = ItemObject.create(param1);
                if ((this.lv + 1) > this.curSuperLevelmax)
                {
                    _loc_5.superlevel = this.curSuperLevelmax;
                }
                else
                {
                    _loc_5.superlevel = this.lv + 1;
                }
                item2.data = _loc_5;
                _loc_6 = 0;
                this.maxObj = _loc_5;
                if (_loc_5.hp > 0)
                {
                    if (this.addspArr.length > (_loc_6 + 1))
                    {
                        this.addspArr[_loc_6].show("血量上限: ", _loc_5.hp, this.getMaxAdd(3));
                        this.addspArr[_loc_6].y = _loc_6;
                        this.addsp.addChild(this.addspArr[_loc_6]);
                    }
                    else
                    {
                        _loc_2 = new QhaddItem("血量上限: ", _loc_5.hp, this.getMaxAdd(3));
                        _loc_2.y = _loc_6;
                        this.addsp.addChild(_loc_2);
                        this.addspArr.push(_loc_2);
                    }
                    _loc_6++;
                }
                if (_loc_5.mp > 0)
                {
                    if (this.addspArr.length > (_loc_6 + 1))
                    {
                        this.addspArr[_loc_6].show("魔法上限: ", _loc_5.mp, this.getMaxAdd(4));
                        this.addspArr[_loc_6].y = _loc_6;
                        this.addsp.addChild(this.addspArr[_loc_6]);
                    }
                    else
                    {
                        _loc_2 = new QhaddItem("魔法上限: ", _loc_5.mp, this.getMaxAdd(4));
                        _loc_2.y = _loc_6;
                        this.addsp.addChild(_loc_2);
                        this.addspArr.push(_loc_2);
                    }
                    _loc_6++;
                }
                if (_loc_5.phyAttMax > 0)
                {
                    if (this.addspArr.length > (_loc_6 + 1))
                    {
                        this.addspArr[_loc_6].show("物理攻击: ", _loc_5.phyAtt + " - " + _loc_5.phyAttMax, this.getMaxAdd());
                        this.addspArr[_loc_6].y = _loc_6;
                        this.addsp.addChild(this.addspArr[_loc_6]);
                    }
                    else
                    {
                        _loc_2 = new QhaddItem("物理攻击: ", _loc_5.phyAtt + " - " + _loc_5.phyAttMax, this.getMaxAdd());
                        _loc_2.y = _loc_6;
                        this.addsp.addChild(_loc_2);
                        this.addspArr.push(_loc_2);
                    }
                    _loc_6++;
                }
                if (_loc_5.magicAttMax > 0)
                {
                    if (this.addspArr.length > (_loc_6 + 1))
                    {
                        this.addspArr[_loc_6].show("魔法攻击: ", _loc_5.magicAtt + " - " + _loc_5.magicAttMax, this.getMaxAdd());
                        this.addspArr[_loc_6].y = _loc_6;
                        this.addsp.addChild(this.addspArr[_loc_6]);
                    }
                    else
                    {
                        _loc_2 = new QhaddItem("魔法攻击: ", _loc_5.magicAtt + " - " + _loc_5.magicAttMax, this.getMaxAdd());
                        _loc_2.y = _loc_6;
                        this.addsp.addChild(_loc_2);
                        this.addspArr.push(_loc_2);
                    }
                    _loc_6++;
                }
                if (_loc_5.taoAttMax > 0)
                {
                    if (this.addspArr.length > (_loc_6 + 1))
                    {
                        this.addspArr[_loc_6].show("道术攻击: ", _loc_5.taoAtt + " - " + _loc_5.taoAttMax, this.getMaxAdd());
                        this.addspArr[_loc_6].y = _loc_6;
                        this.addsp.addChild(this.addspArr[_loc_6]);
                    }
                    else
                    {
                        _loc_2 = new QhaddItem("道术攻击: ", _loc_5.taoAtt + " - " + _loc_5.taoAttMax, this.getMaxAdd());
                        _loc_2.y = _loc_6;
                        this.addsp.addChild(_loc_2);
                        this.addspArr.push(_loc_2);
                    }
                    _loc_6++;
                }
                if (_loc_5.phyDefMax > 0)
                {
                    if (this.addspArr.length > (_loc_6 + 1))
                    {
                        this.addspArr[_loc_6].show("物理防御: ", _loc_5.phyDef + " - " + _loc_5.phyDefMax, this.getMaxAdd(2));
                        this.addspArr[_loc_6].y = _loc_6;
                        this.addsp.addChild(this.addspArr[_loc_6]);
                    }
                    else
                    {
                        _loc_2 = new QhaddItem("物理防御: ", _loc_5.phyDef + " - " + _loc_5.phyDefMax, this.getMaxAdd(2));
                        _loc_2.y = _loc_6;
                        this.addsp.addChild(_loc_2);
                        this.addspArr.push(_loc_2);
                    }
                    _loc_6++;
                }
                if (_loc_5.magicDefMax > 0)
                {
                    if (this.addspArr.length > (_loc_6 + 1))
                    {
                        this.addspArr[_loc_6].show("魔法防御: ", _loc_5.magicDef + " - " + _loc_5.magicDefMax, this.getMaxAdd(2));
                        this.addspArr[_loc_6].y = _loc_6;
                        this.addsp.addChild(this.addspArr[_loc_6]);
                    }
                    else
                    {
                        _loc_2 = new QhaddItem("魔法防御: ", _loc_5.magicDef + " - " + _loc_5.magicDefMax, this.getMaxAdd(2));
                        _loc_2.y = _loc_6;
                        this.addsp.addChild(_loc_2);
                        this.addspArr.push(_loc_2);
                    }
                    _loc_6++;
                }
            }
            if (param1.superlevel < param1.qhmax && this._cfgNewQh[param1.superlevel])
            {
                this.upvalue = int(this._cfgNewQh[param1.superlevel][0].value);
                _loc_7 = int(this._cfgNewQh[param1.superlevel][0].money);
                _loc_8 = int(this._cfgNewQh[param1.superlevel][0].cost);
                this.stripMc = XMLMcManager.instance.getPluginMc("qianghua", "qh_jindutiao");
                if (param1.superlevel >= 10)
                {
                    this.isShow = true;
                    jdtw.visible = true;
                    jdtw.width = int(param1.upvalue / this.upvalue * this._jdtw);
                    if (this.stripMc)
                    {
                        if (!this.shap)
                        {
                            this.shap = new Shape();
                            this.shap.graphics.beginFill(0, 1);
                            this.shap.graphics.drawRect(0, 0, 444, 80);
                            this.shap.graphics.endFill();
                            this.shap.x = jdtw.x + 2;
                            this.shap.y = jdtw.y - 20;
                            this.addChild(this.shap);
                        }
                        this.stripMc.mouseEnabled = false;
                        this.stripMc.mouseChildren = false;
                        this.stripMc.blendMode = BlendMode.ADD;
                        this.stripMc.y = jdtw.y - 35;
                        this.stripMc.play();
                        this.stripMc.visible = true;
                        this.stripMc.mask = this.shap;
                        this.stripMc.x = this.stripMc.x + (jdtw.x + 2 - 530 + 116 + jdtw.width);
                        this.addChild(this.stripMc);
                    }
                }
                else
                {
                    this.isShow = false;
                    this.clearMcEffect();
                }
            }
            else
            {
                this.isShow = false;
                this.clearMcEffect();
            }
            this.showPower(param1.upvalue);
            item1.visible = true;
            item2.visible = true;
            clitem.visible = true;
            if (param1.superlevel < param1.qhmax)
            {
                _loc_9 = (this._cfgNewQh[param1.superlevel][0].needitem as String).split("#");
                _loc_10 = _loc_9[0];
                clitem.data = ItemObject.create(this._cfgitems[_loc_10]);
                _loc_11 = ItemUilt.getAllCount(_loc_10);
                _loc_12 = int(_loc_9[1]);
                _loc_13 = ModelProxy.getValue("data", "bag.money");
                if (_loc_11 >= _loc_12)
                {
                    cl_txt.color = 5485622;
                }
                else
                {
                    cl_txt.color = MColor.New9;
                }
                cl_txt.text = String(_loc_11) + "/" + _loc_12;
                _loc_14 = Constant.ITEM_QHBHF;
                item3.data = ItemObject.create(this._cfgitems[_loc_14]);
                _loc_15 = ItemUilt.getAllCount(Constant.ITEM_QHBHF);
                _loc_16 = this._cfgNewQh[this.curSuperLevel][0].needpronum;
                if (_loc_15 >= _loc_16)
                {
                    bhftext.color = 5485622;
                }
                else
                {
                    bhftext.color = MColor.New9;
                }
                bhftext.text = String(_loc_15) + "/" + String(_loc_16);
                jb_txt.text = this._cfgNewQh[param1.superlevel][0].money;
                _loc_17 = int(this._cfgNewQh[param1.superlevel][0].rate);
                _loc_18 = _loc_17 / 10000;
                if (cbb.selected == true)
                {
                    gailvLabel.text = "成功概率：100%";
                }
                else
                {
                    _loc_20 = ModelProxy.getValue("vip", "getvip");
                    _loc_21 = ConfigDictionary.data.tequan;
                    if (_loc_20.privilegeCardLevel >= 1)
                    {
                        _loc_22 = 100 * _loc_18 * (1 + int(_loc_21[_loc_20.privilegeCardLevel].qianghuap) / 100);
                        if (_loc_18 == 1)
                        {
                            gailvLabel.text = "成功概率：" + (_loc_18 * 100 as Number).toFixed(0) + "%";
                        }
                        else
                        {
                            if (_loc_22 > 100)
                            {
                                _loc_22 = 100;
                            }
                            gailvLabel.text = "成功概率：" + (_loc_22 as Number).toFixed(0) + "%" + "<font color=\'#ff0000\'>（特权+" + _loc_21[_loc_20.privilegeCardLevel].qianghuap + "%）</font>";
                        }
                    }
                    else
                    {
                        gailvLabel.text = "成功概率：" + (_loc_18 * 100 as Number).toFixed(0) + "%";
                    }
                }
                if (param1.superlevel >= 6)
                {
                    if (_loc_18 * 100 == 100)
                    {
                        var _loc_23:Boolean = false;
                        qhbhfBox.visible = false;
                        bhfBox.visible = _loc_23;
                    }
                    else
                    {
                        var _loc_23:Boolean = true;
                        qhbhfBox.visible = true;
                        bhfBox.visible = _loc_23;
                    }
                }
                else
                {
                    var _loc_23:Boolean = false;
                    qhbhfBox.visible = false;
                    bhfBox.visible = _loc_23;
                }
                _loc_19 = this._cfgitems[_loc_10].name;
                this.showYuanbao();
            }
            else
            {
                this.stripMc.visible = false;
                this.stripMc.stop();
            }
            if (param1.superlevel < 10)
            {
                gailvLabel.visible = true;
                cbb.visible = true;
                jdtw.visible = false;
                jdt.visible = true;
                if (this.stripMc)
                {
                    this.stripMc.visible = false;
                    this.stripMc.stop();
                }
                this.powerSprite.visible = false;
                btn_qh.label = "强化";
                btn_qh.x = 315 + 18;
                btn_yjqh.visible = false;
            }
            else
            {
                jdtw.visible = true;
                jdt.visible = true;
                if (this.stripMc)
                {
                    this.stripMc.visible = true;
                    this.stripMc.play();
                }
                gailvLabel.visible = false;
                cbb.visible = false;
                cbb.selected = false;
                this.powerSprite.visible = true;
                btn_qh.label = "铸造";
                btn_qh.x = 243;
                btn_yjqh.visible = true;
                btn_yjqh.label = "一键铸造";
            }
            if (param1.superlevel < 6)
            {
                cbox.selected = false;
                cbb.selected = false;
                var _loc_23:Boolean = false;
                ybBox.visible = false;
                ybdtBox.visible = _loc_23;
                jbBox.x = 322;
                jbBox.y = 332;
            }
            else
            {
                var _loc_23:Boolean = true;
                ybBox.visible = true;
                ybdtBox.visible = _loc_23;
                jbBox.x = 214;
                jbBox.y = 320;
            }
            this.showEffect();
            return;
        }// end function

        private function showYuanbao() : void
        {
            var _loc_1:int = 0;
            var _loc_2:Number = NaN;
            var _loc_3:Object = null;
            var _loc_4:Object = null;
            var _loc_5:Number = NaN;
            var _loc_6:Array = null;
            var _loc_7:int = 0;
            var _loc_8:int = 0;
            var _loc_9:int = 0;
            var _loc_10:int = 0;
            var _loc_11:int = 0;
            if (item1.data.icon != "")
            {
                if (cbb.selected == true)
                {
                    gailvLabel.text = "成功概率：100%";
                }
                else
                {
                    _loc_1 = int(this._cfgNewQh[item1.data.superlevel][0].rate);
                    _loc_2 = _loc_1 / 10000;
                    _loc_3 = ModelProxy.getValue("vip", "getvip");
                    _loc_4 = ConfigDictionary.data.tequan;
                    if (_loc_3.privilegeCardLevel >= 1)
                    {
                        _loc_5 = 100 * _loc_2 * (1 + int(_loc_4[_loc_3.privilegeCardLevel].qianghuap) / 100);
                        if (_loc_2 == 1)
                        {
                            gailvLabel.text = "成功概率：" + (_loc_2 * 100 as Number).toFixed(0) + "%";
                        }
                        else
                        {
                            if (_loc_5 > 100)
                            {
                                _loc_5 = 100;
                            }
                            gailvLabel.text = "成功概率：" + (_loc_5 as Number).toFixed(0) + "%" + "<font color=\'#ff0000\'>（特权+" + _loc_4[_loc_3.privilegeCardLevel].qianghuap + "%）</font>";
                        }
                    }
                    else
                    {
                        gailvLabel.text = "成功概率：" + (_loc_2 * 100 as Number).toFixed(0) + "%";
                    }
                }
                if (this.curSuperLevel < this.curSuperLevelmax)
                {
                    if (this.curSuperLevel >= 10)
                    {
                        cbb.selected = false;
                    }
                    _loc_6 = (this._cfgNewQh[this.curSuperLevel][0].needitem as String).split("#");
                    _loc_7 = int(_loc_6[0]);
                    _loc_8 = int(_loc_6[1]);
                    _loc_9 = ItemUilt.getAllCount(_loc_7);
                    _loc_10 = ItemUilt.getAllCount(Constant.ITEM_QHBHF);
                    _loc_11 = this._cfgNewQh[this.curSuperLevel][0].needpronum;
                    if (cbox.selected && !cbb.selected)
                    {
                        if (_loc_9 >= _loc_8)
                        {
                            yb_txt.text = "0";
                        }
                        else if (this.curSuperLevel < 6)
                        {
                            yb_txt.text = String(this.yuanbao1 * (_loc_8 - _loc_9));
                        }
                        else if (this.curSuperLevel < 10)
                        {
                            yb_txt.text = String(this.yuanbao2 * (_loc_8 - _loc_9));
                        }
                        else if (this.curSuperLevel < 15)
                        {
                            yb_txt.text = String(this.yuanbao3 * (_loc_8 - _loc_9));
                        }
                        else
                        {
                            yb_txt.text = String(this.yuanbao4 * (_loc_8 - _loc_9));
                        }
                    }
                    else if (!cbox.selected && cbb.selected)
                    {
                        if (_loc_10 < _loc_11)
                        {
                            ModelProxy.change("movetips", "error", "强化保护符不足");
                        }
                        yb_txt.text = "0";
                    }
                    else if (cbox.selected && cbb.selected)
                    {
                        if (_loc_9 >= _loc_8 && _loc_10 >= _loc_11)
                        {
                            yb_txt.text = "0";
                        }
                        else if (_loc_9 >= _loc_8 && _loc_10 < _loc_11)
                        {
                            yb_txt.text = String(this.yuanbao5 * (_loc_11 - _loc_10));
                        }
                        else if (_loc_9 < _loc_8 && _loc_10 >= _loc_11)
                        {
                            if (this.curSuperLevel < 6)
                            {
                                yb_txt.text = String(this.yuanbao1 * (_loc_8 - _loc_9));
                            }
                            else if (this.curSuperLevel < 10)
                            {
                                yb_txt.text = String(this.yuanbao2 * (_loc_8 - _loc_9));
                            }
                            else if (this.curSuperLevel < 15)
                            {
                                yb_txt.text = String(this.yuanbao3 * (_loc_8 - _loc_9));
                            }
                            else
                            {
                                yb_txt.text = String(this.yuanbao4 * (_loc_8 - _loc_9));
                            }
                        }
                        else if (this.curSuperLevel < 6)
                        {
                            yb_txt.text = String(this.yuanbao1 * (_loc_8 - _loc_9) + this.yuanbao5 * (_loc_11 - _loc_10));
                        }
                        else if (this.curSuperLevel < 10)
                        {
                            yb_txt.text = String(this.yuanbao2 * (_loc_8 - _loc_9) + this.yuanbao5 * (_loc_11 - _loc_10));
                        }
                        else if (this.curSuperLevel < 15)
                        {
                            yb_txt.text = String(this.yuanbao3 * (_loc_8 - _loc_9) + this.yuanbao5 * (_loc_11 - _loc_10));
                        }
                        else
                        {
                            yb_txt.text = String(this.yuanbao4 * (_loc_8 - _loc_9) + this.yuanbao5 * (_loc_11 - _loc_10));
                        }
                    }
                    else
                    {
                        yb_txt.text = "0";
                    }
                }
            }
            return;
        }// end function

        private function getMaxAdd(param1:int = 1) : int
        {
            var _loc_4:int = 0;
            var _loc_2:* = this.maxObj.level + "#" + this.maxObj.superlevel;
            var _loc_3:int = 0;
            if (this.arr[_loc_2])
            {
                _loc_4 = 1;
                while (_loc_4 <= this.maxObj.superlevel)
                {
                    
                    if (param1 == 1)
                    {
                        _loc_3 = _loc_3 + int(this.arr[this.maxObj.level + "#" + _loc_4].attadd);
                    }
                    else if (param1 == 2)
                    {
                        _loc_3 = _loc_3 + int(this.arr[this.maxObj.level + "#" + _loc_4].defadd);
                    }
                    else if (param1 == 3)
                    {
                        _loc_3 = _loc_3 + int(this.arr[this.maxObj.level + "#" + _loc_4].hpadd);
                    }
                    else if (param1 == 4)
                    {
                        _loc_3 = _loc_3 + int(this.arr[this.maxObj.level + "#" + _loc_4].mpadd);
                    }
                    _loc_4++;
                }
            }
            return _loc_3;
        }// end function

        public function clear() : void
        {
            if (this._curobj)
            {
                if (this._curobj.id != this.armid)
                {
                    this.oPower = 0;
                }
            }
            this.index = 0;
            item1.visible = false;
            item2.visible = false;
            clitem.visible = false;
            if (this.mc)
            {
                this.mc.visible = false;
                this.mc.stop();
            }
            this.clearMcEffect();
            this.curpower = 0;
            this.armid = 0;
            var _loc_1:int = 1;
            while (_loc_1 <= 10)
            {
                
                this["star" + _loc_1].visible = false;
                _loc_1++;
            }
            DestroyUtil.removeChildren(this.addsp);
            item1.data = null;
            item2.data = null;
            clitem.data = null;
            item3.data = null;
            gailvLabel.text = "成功概率：";
            cl_txt.text = "";
            jb_txt.text = "";
            yb_txt.text = "";
            bhftext.text = "";
            img1.visible = false;
            img2.visible = false;
            img3.visible = false;
            img4.visible = false;
            return;
        }// end function

        public function qiangHuaSuc(param1:Object) : void
        {
            var _loc_2:Object = null;
            if (this._curobj.itemid == param1[1].itemid)
            {
                this._curobj.superlevel = param1[1].superlevel;
                this._curobj.upvalue = param1[1].upvalue;
            }
            var _loc_3:* = this._curobj;
            if (this.type == 2)
            {
                if (int(_loc_3.superlevel) > this.lv)
                {
                    this.showQhSuccessMC();
                    this.lv = _loc_3.superlevel;
                    this.clearMcEffect();
                    setTimeout(this.showEffect1, 500);
                    ModelProxy.change("movetips1", "error", MColor.getHMTL("[" + _loc_3.name + "] 星级 +1", 6));
                    _loc_2 = ModelProxy.getValue("localCache", "option");
                    if (_loc_2 && _loc_2.offbasesound != 1)
                    {
                        ModelProxy.change("main", "playsound", SoundType.BTN_QIANGHUA);
                    }
                }
                else
                {
                    if (this.armid == 0 || this.armid == this._curobj.id)
                    {
                        this.showItem(this._curobj);
                    }
                    setTimeout(this.onQiangHua, 200);
                }
            }
            else
            {
                if (int(_loc_3.superlevel) > this.lv)
                {
                    this.showQhSuccessMC();
                    this.clearMcEffect();
                    this.showEffect1();
                    ModelProxy.change("movetips1", "error", MColor.getHMTL("[" + _loc_3.name + "] 星级 +1", 6));
                }
                else
                {
                    if (gailvLabel.visible == true)
                    {
                        this.showQhFailMC();
                    }
                    ModelProxy.change("data", "qhflag", false);
                    this.setVisible();
                    if (this._curobj.upvalue - this.lvvalue > 1)
                    {
                        ModelProxy.change("movetips1", "error", MColor.getHMTL("[" + _loc_3.name + "] 强化值增加&lt;暴击&gt;", 6));
                    }
                    else
                    {
                        ModelProxy.change("movetips1", "error", MColor.getHMTL("[" + _loc_3.name + "] 强化值增加", 6));
                    }
                    if (this.armid == 0 || this.armid == this._curobj.id)
                    {
                        this.showItem(this._curobj);
                    }
                }
                _loc_2 = ModelProxy.getValue("localCache", "option");
                if (_loc_2 && _loc_2.offbasesound != 1)
                {
                    ModelProxy.change("main", "playsound", SoundType.BTN_QIANGHUA);
                }
            }
            return;
        }// end function

        private function showQhSuccessMC() : void
        {
            if (this.failMc)
            {
                this.failMc.visible = false;
                this.failMc.stop();
                setTimeout(this.showSuccess, 50);
            }
            return;
        }// end function

        private function showSuccess() : void
        {
            if (this.successMc)
            {
                this.successMc.playFromTo(-1, (this.successMc.totalFrame - 1), new Handler(this.doEnd1));
                this.successMc.visible = true;
            }
            return;
        }// end function

        private function doEnd1() : void
        {
            if (this.successMc)
            {
                this.successMc.visible = false;
                this.successMc.stop();
            }
            return;
        }// end function

        private function showQhFailMC() : void
        {
            if (this.successMc)
            {
                this.successMc.visible = false;
                this.successMc.stop();
                setTimeout(this.showFail, 50);
            }
            return;
        }// end function

        private function showFail() : void
        {
            if (this.failMc)
            {
                this.failMc.playFromTo(-1, (this.failMc.totalFrame - 1), new Handler(this.doEnd2));
                this.failMc.visible = true;
            }
            return;
        }// end function

        private function doEnd2() : void
        {
            if (this.failMc)
            {
                this.failMc.visible = false;
                this.failMc.stop();
            }
            return;
        }// end function

        private function showEffect() : void
        {
            if (this.mc)
            {
                this.mc.x = this["star" + (this.pos + 1)].x - 18 - 8;
                this.mc.y = this["star" + (this.pos + 1)].y - 18 - 8;
                this.mc.visible = true;
                this.mc.play();
            }
            return;
        }// end function

        private function showEffect1() : void
        {
            this.doSuc();
            return;
        }// end function

        public function setVisible() : void
        {
            btn_qh.disabled = false;
            btn_yjqh.disabled = false;
            return;
        }// end function

        private function doSuc() : void
        {
            ModelProxy.change("data", "qhflag", false);
            this.setVisible();
            jdtw.width = 0;
            if (this.armid == 0 || this.armid == this._curobj.id)
            {
                this.showItem(this._curobj);
            }
            return;
        }// end function

        public function Qqsbuzupc(param1:Object) : void
        {
            cbox.label = "强化石不足时以单价" + param1 + "元宝从商城自动购入";
            return;
        }// end function

        private function overHandler(event:MouseEvent) : void
        {
            this.showArmTZTips();
            ModelProxy.change("tips", "normal", {data:this._qhtzTips, p:new Point(2, 2)});
            return;
        }// end function

        public function showArmTZTips() : void
        {
            var _loc_10:String = null;
            var _loc_11:Object = null;
            var _loc_12:Object = null;
            var _loc_13:int = 0;
            var _loc_14:int = 0;
            var _loc_15:Array = null;
            var _loc_16:int = 0;
            var _loc_17:int = 0;
            var _loc_18:Array = null;
            var _loc_19:int = 0;
            var _loc_20:int = 0;
            var _loc_21:int = 0;
            var _loc_1:* = ModelProxy.getValue("data", "arms");
            var _loc_2:* = new Object();
            var _loc_3:Array = [];
            var _loc_4:Array = [];
            var _loc_5:* = "<font color=\'" + MColor.Newstr82 + "\' size=\'14\'>强化效果加成</font>\n";
            var _loc_6:int = 0;
            var _loc_7:int = 1;
            while (_loc_7 <= 16)
            {
                
                _loc_12 = _loc_1[_loc_7];
                if (_loc_12)
                {
                    _loc_13 = _loc_12.superlevel;
                    if (_loc_13 > 0)
                    {
                        _loc_14 = 1;
                        while (_loc_14 <= _loc_13)
                        {
                            
                            _loc_2[_loc_14] = int(_loc_2[_loc_14]) + 1;
                            _loc_14++;
                        }
                    }
                    if (_loc_12.suitid == 1 || _loc_12.suitid == 3)
                    {
                        if (_loc_12.appraisal)
                        {
                            _loc_15 = _loc_12.appraisal;
                            _loc_16 = 0;
                            while (_loc_16 < _loc_15.length)
                            {
                                
                                _loc_17 = _loc_15[_loc_16] >> this.curSuperLevelmax;
                                if (_loc_17 > 0)
                                {
                                    _loc_3[_loc_17] = int(_loc_3[_loc_17]) + 1;
                                }
                                _loc_16++;
                            }
                        }
                        if (_loc_12.xq)
                        {
                            _loc_18 = _loc_12.xq;
                            _loc_19 = 0;
                            for each (_loc_20 in _loc_18)
                            {
                                
                                if (this.cfgitem[_loc_20])
                                {
                                    _loc_4[int(this.cfgitem[_loc_20].level)] = int(_loc_4[int(this.cfgitem[_loc_20].level)]) + 1;
                                }
                            }
                        }
                    }
                }
                _loc_7++;
            }
            var _loc_8:Object = null;
            var _loc_9:Object = null;
            for each (_loc_11 in this.qhtz)
            {
                
                _loc_21 = 2;
                if (_loc_2[_loc_11.lv] >= _loc_11.count)
                {
                    _loc_21 = 8;
                    if (_loc_6 < _loc_11.lv)
                    {
                        _loc_6 = _loc_11.lv;
                    }
                    if (_loc_9 == null)
                    {
                        _loc_9 = new Object();
                    }
                    _loc_9.count = _loc_11.count;
                    _loc_9.lv = _loc_11.lv;
                    for (_loc_10 in _loc_11)
                    {
                        
                        if (_loc_10 == "id" || _loc_10 == "count" || _loc_10 == "lv" || _loc_10 == "addper")
                        {
                            continue;
                        }
                        if (_loc_9[_loc_10] == null)
                        {
                            _loc_9[_loc_10] = 0;
                        }
                        _loc_9[_loc_10] = int(_loc_11[_loc_10]);
                    }
                    continue;
                }
                if (_loc_8 == null)
                {
                    _loc_8 = new Object();
                    for (_loc_10 in _loc_11)
                    {
                        
                        if (_loc_10 == "id" || _loc_10 == "count" || _loc_10 == "lv" || _loc_10 == "addper")
                        {
                            _loc_8[_loc_10] = int(_loc_11[_loc_10]);
                            continue;
                        }
                        if (_loc_9)
                        {
                            _loc_8[_loc_10] = int(_loc_11[_loc_10]);
                            continue;
                        }
                        _loc_8[_loc_10] = int(_loc_11[_loc_10]);
                    }
                    break;
                }
            }
            _loc_5 = _loc_5 + MColor.getHMTL("\n当前效果:\n", 55);
            if (_loc_9 == null)
            {
                _loc_5 = _loc_5 + MColor.getHMTL("无\n", 65);
            }
            else
            {
                _loc_5 = _loc_5 + MColor.getHMTL(_loc_9.count + "件装备强化+" + _loc_9.lv, 83);
                _loc_5 = _loc_5 + ("<font color=\'#00ff00\'>  (" + int(_loc_2[_loc_9.lv]) + "/" + _loc_9.count + ")(激活)</font>\n");
                _loc_5 = _loc_5 + ("<font color=\'#53b436\'>全身装备强化属性 +" + _loc_9.show / 100 + "%</font>\n");
            }
            if (_loc_8)
            {
                _loc_5 = _loc_5 + MColor.getHMTL("\n下级效果:\n", 55);
                _loc_5 = _loc_5 + MColor.getHMTL(_loc_8.count + "件装备强化+" + _loc_8.lv, 4);
                _loc_5 = _loc_5 + ("<font color=\'#ff0000\'>  (" + int(_loc_2[_loc_8.lv]) + "/" + _loc_8.count + ")(未激活)</font>\n");
                _loc_5 = _loc_5 + ("<font color=\'#94928c\'>全身装备强化属性 +" + _loc_8.show / 100 + "%</font>\n");
            }
            this._qhtzTips = _loc_5;
            return;
        }// end function

        private function outHandler(event:MouseEvent) : void
        {
            ModelProxy.change("tips", "state", "close");
            return;
        }// end function

        private function clearMcEffect() : void
        {
            if (this.shap)
            {
                if (this.shap.parent)
                {
                    this.shap.parent.removeChild(this.shap);
                }
                this.shap = null;
            }
            if (this.stripMc)
            {
                if (this.stripMc.parent)
                {
                    this.stripMc.parent.removeChild(this.stripMc);
                }
                this.stripMc.stop();
                this.stripMc.x = 0;
            }
            return;
        }// end function

        public function clearEffect() : void
        {
            this.clearMcEffect();
            if (this.mc)
            {
                if (this.mc.parent)
                {
                    this.mc.parent.removeChild(this.mc);
                }
                this.mc.stop();
            }
            return;
        }// end function

    }
}
